//@ts-nocheck

import * as vue from 'vue';
window.Vue = vue; 

// import { createPinia } from 'pinia'

import App from './App.vue';
import router from './router';
import { createI18n }  from 'vue-i18n';
import * as VueI18n from 'vue-i18n';
window.VueI18n = VueI18n;
const resourceURL = window.TeldWebConfig.ResourceURL;
let teldLocale = TFF.common.storage.Cookie.read('teld_locale');
if(!teldLocale){
  teldLocale = TFF.common.storage.Cookie.read('wrp_locale');
}
if(!teldLocale && navigator.language){ 
  teldLocale = navigator.language;
}

if(!teldLocale){
  teldLocale = 'zh-CN';
}

// 引入全局样式
import './assets/main.scss'

// 导入主题服务
import { initTheme } from './service/commonService';

// 初始化系统主题
initTheme();

const app = vue.createApp(App);

const messages = {};
messages[ teldLocale ] = window.localeMessage??{};


const i18n = createI18n({
  legacy:false,
  locale: teldLocale, 
  messages
});

// app.use(createPinia())
app.use(router);
app.use(i18n);
let AppCode = import.meta.env.VITE_APP_CODE;

if(process.env.NODE_ENV === 'development'){
  AppCode = 'app'
}
import(`/tff/component/pc/umd/index.js?url`).then(()=>{
  import(`/tff/component/mobile/umd/index.js?url`).then(()=>{
    app.use(window.tm.default, { language: teldLocale??'zh-CN' });
    app.use(window.TComponents.default, { language: teldLocale??'zh-CN' });
    router.isReady().then(() => {
      //@ts-ignore
      app.mount(`#${AppCode}`, {
        language: teldLocale??'zh-CN',
      });
    });
  });
  
});

window.fasAppInstance = app;

